package com.learn.xueer.ui.adapter

import android.widget.ImageView
import com.blankj.utilcode.util.SizeUtils
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.bitmap.CircleCrop
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
import com.bumptech.glide.request.RequestOptions
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.learn.xueer.R
import com.learn.xueer.app.util.CornerTransform
import com.learn.xueer.data.model.bean.BookSectionResponse
import com.learn.xueer.data.model.bean.VipList
import com.learn.xueer.data.model.bean.VipResponse

class VipAdapter(data: MutableList<VipList>) :
    BaseQuickAdapter<VipList, BaseViewHolder>(
        R.layout.item_vip, data
    ) {
    override fun convert(holder: BaseViewHolder, item: VipList) {
        holder.setText(R.id.tv_name, item.name)
        //1小学,2初中,3高中
        var grade = if (item.grade_type == "1") {
            "小学"
        } else if (item.grade_type == "2") {
            "初中"
        } else if (item.grade_type == "3") {
            "高中"
        } else {
            ""
        }
        holder.setText(R.id.tv_grade, "适用于：$grade")
        if (!item.image.isNullOrEmpty()) {
            var view = holder.getView<ImageView>(R.id.iv_logo)
            Glide.with(this.context)
                .load(item.image)
                .centerCrop()
                .apply(
                    RequestOptions.bitmapTransform(
                        CornerTransform(
                            this.context,
                            SizeUtils.dp2px(15f).toFloat()
                        )
                    )
                )
                .placeholder(R.mipmap.default_book)
                .error(R.mipmap.default_book)
                .into(view)
        }


    }
}